# Contributor: mekyt <hello@mek.yt>
# Maintainer: mekyt <hello@mek.yt>
pkgname=zulip-desktop
pkgver=5.11.1
pkgrel=2
pkgdesc="Desktop application for Zulip, an open source chat and collaborative software"
url="https://github.com/zulip/zulip-desktop"
# same as electron
arch="aarch64 x86_64"
license="Apache-2.0"
depends="
	electron
"
makedepends="
	electron-tasje
	nodejs
	npm
	pnpm
"
options="net !check"

source="
	$pkgname-$pkgver.tar.gz::https://github.com/zulip/zulip-desktop/archive/refs/tags/v$pkgver.tar.gz
	disable-auto-update.patch
	$pkgname
	$pkgname.desktop
"

build() {
	pnpm install --ignore-scripts
	pnpm dlx vite build
	pnpm prune --prod --ignore-scripts

	tasje pack
}

package() {
	cd "$srcdir"

	install -Dm644 $pkgname.desktop "$pkgdir"/usr/share/applications/$pkgname.desktop
	install -Dm755 $pkgname "$pkgdir"/usr/bin/$pkgname

	cd "$builddir"

	install -Dm644 tasje_out/resources/app.asar "$pkgdir"/usr/lib/$pkgname/app.asar

	while read -r size; do
		install -Dm644 tasje_out/icons/$size.png "$pkgdir"/usr/share/icons/hicolor/$size/apps/zulip.png
	done < tasje_out/icons/size-list
}

sha512sums="
eefa4240af971329ddc1be0360ddfd83f04cf88f16044842f7a42b3ae4a2dba34432fbfeaf4428cfc16cf4a9804e6b04a74740a370fffa7aa9620ef7ce9e9672  zulip-desktop-5.11.1.tar.gz
aca3d70c2da708a83a51aabbdfafe68bee9fc77d8a13bb8dddba39b240652c16c40ac5ef4cdf03c7f5ed6a227285c08354703d95b6c06dfdbbd75794c4b957aa  disable-auto-update.patch
9e2d8aa4cfde943c3d8827fb36511848902852f55fe8d6899c0097a0f15ad37e0c5f0e0b6d530cbfda2f6aacd5d77e4cfb5c2a4438ec34bf174bca41cb25a2a7  zulip-desktop
a893639364d2b972de7b29c7ea7399a79d818cf9dc0f3df7c6aaa9e349803fa187f7030c12ae81881f7f2eef9d2aecca22a9e1bf0b7198726a993ea6a5f368ed  zulip-desktop.desktop
"
